package com.dreamer.service.pyramid;

import com.dreamer.domain.pyramid.PyramidUser;
import com.dreamer.domain.pyramid.PyramidUserVo;
import com.dreamer.repository.pyramid.PyramidUserDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ps.mx.otter.utils.SearchParameter;

import java.util.List;

@Service
public class PyramidUserHandler {

    @Autowired
    private PyramidUserDAO pyramidUserDAO;

    @Transactional
    public PyramidUser saveOrupdate(PyramidUser pyramidUser){
        PyramidUser instance = pyramidUserDAO.merge(pyramidUser);
        LOG.debug("新增活动成功"+instance);
        return pyramidUser;
    }

    @Transactional
    public void removeActivity(PyramidUser pyramidUser) {
        pyramidUserDAO.delete(pyramidUser);
        LOG.debug("删除活动成功");
    }

    private final Logger LOG = LoggerFactory.getLogger(getClass());

    public PyramidUser findById(Integer integer) {
        return  pyramidUserDAO.findById(integer);
    }

    public PyramidUserVo findByIdVo(Integer integer) {
        return  pyramidUserDAO.findByIdVo(integer);
    }

    public List<PyramidUser> searchAllByPage(SearchParameter<PyramidUser> parameter) {
        return pyramidUserDAO.searchAllByPage(parameter);
    }

    public List<PyramidUser> findAll(){
        return pyramidUserDAO.findAll();
    }

    public List<PyramidUserVo> findPyramidVoAll(SearchParameter<PyramidUserVo> p){
        return pyramidUserDAO.findPyramidVoAll(p);
    }

}
